package testApplets;

import java.io.File;
import java.util.Vector;

import processing.core.PApplet;
import simpleGeom.Mesh;



public class MeshAnalyse extends PApplet {
	public void setup(){
		analyseVolume();
	}
	public void analyseAll(){
		Vector<File> files=loadFilesFromFolder(new File(this.selectFolder()));
		Mesh mesh=new Mesh();
		float sumVolume=0;
		for (int i=0;i<files.size();i++){
			File file=files.get(i);
			mesh.loadMesh(file.getAbsolutePath());
			float cVolume=mesh.getVolumeOfSolid();
			sumVolume+=cVolume;
			println(cVolume);
		}
		println("total: "+sumVolume);
	}
	public void draw(){
		
	}
	public void analyseVolume(){
		Mesh mesh=new Mesh();
		float sumVolume=0;
		
			mesh.loadMesh(this.selectInput());
			float cVolume=mesh.getVolumeOfSolid();
			
		println("total: "+cVolume);
	}
	public Vector<File> loadFilesFromFolder( File folder){
		Vector<File>allFiles=new Vector<File>();
		    for (final File fileEntry : folder.listFiles()) {
		        if (fileEntry.isFile()) {
		        	allFiles.add(fileEntry);  
		        }
		  }
		    return allFiles;
	}
	
}
